<template>
    <div>
        <img class="img" src="../../assets/img/4.png" alt="" />
        <div class="flex mt-30">
            <div class="xzon" v-for="item in searchTabs" :key="item.val" :class="{ active: currTab == item.val }"
                @click="currTab = item.val">
                {{ item.label }}
            </div>
        </div>
        <div style="margin-top: 18px">
            <el-input placeholder="请输入内容" v-model="keywords">
                <el-button slot="append" icon="el-icon-search">搜索</el-button>
            </el-input>
        </div>
        <div class="flex p-10">
            <div class="name">热词：</div>
            <div class="names" v-for="item in hotKeys" :key="item.id" @click="headleClick(item)">{{ item.title }}</div>
        </div>
    </div>
</template>

<script>
import { getSearchList } from '@/api/apis'
export default {
    name: 'search',
    props: {

    },
    data () {
        return {
            keywords: "",
            currTab: 0,
            searchTabs: [
                {
                    val: 0,
                    label: '咨询'
                },
                {
                    val: 1,
                    label: '装备'
                },
                {
                    val: 2,
                    label: '供应商'
                },
                {
                    val: 3,
                    label: '招投标'
                },
            ],
            hotKeys: ['雷达生命检测仪', '测温仪', '液压破拆工具'],
        }
    },
    mounted () {
        this.getSearchList()
    },
    methods: {
        getSearchList(){
            getSearchList().then(res=>{
                if(res.code === 1){
                    this.hotKeys = res.data
                }
            })
        },
        headleClick(item){
            this.keywords = item.title;
        }
    },
}
</script>

<style scoped lang="less">
.img {
    width: 211px;
    height: 105px;
}

.xzon {
    font-weight: normal;
    font-size: 16px;
    color: #fff;
    padding: 5px 20px;
    border-radius: 5px;
    position: relative;
    cursor: pointer;

    &:hover {
        color: rgba(255, 255, 255, .6);
    }

    &.active {
        color: #ef312a;
        background: #fff;

        &::before {
            content: '';
            position: absolute;
            bottom: -8px;
            bottom: -6px;
            left: 30px;
            width: 13px;
            height: 13px;
            background: #fff;
            border-bottom: 1px solid #fff;
            border-right: 1px solid #fff;
            transform: rotate(45deg);
        }
    }
}

.name {
    font-weight: normal;
    font-size: 14px;
    color: #ffffff;
}

.names {
    font-weight: normal;
    font-size: 14px;
    color: #ffffff;
    margin-left: 10px;
    cursor: pointer;
}

/deep/.el-input-group__append {
    background: #ffbd39;
    border: 1px solid #ffbd39;
    color: #ffffff;
    font-size: 16px;
}

/deep/.el-input__inner {
    height: 60px !important;
}
</style>